package com.xsq.wifi.utils;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * 编写人：李振德
 * 创建时间：2025/05/07
 */
public class ActivityCollector {

    public static List<Activity> activities = new ArrayList<>();

    public static void addActivity(Activity activity) {
        if (activity != null && !activities.contains(activity)) {
            activities.add(activity);
        }
    }

    public static Activity getTopActivity() {
        if (null != activities && activities.size() > 0) {
            return activities.get(0);
        } else {
            return null;
        }
    }

    public static void removeActivity(Activity activity) {
        if (activity != null && activities.contains(activity)) {
            activities.remove(activity);
        }
    }

    public static void finishAll() {
        for (Activity a : activities) {
            a.finish();
        }
    }
}
